import { getGoodsTypePicDataByIdData } from "@/apis/goodsType";
import { useRoute, onBeforeRouteUpdate } from "vue-router";
import { onMounted, ref } from "vue";

export function useGoodsTypePicData() {
    const route = useRoute()
    const goodsTypePicData = ref([])
    const getGoodsTypePicDataById = async (id = route.params.id) => {
        const res = await getGoodsTypePicDataByIdData(id);
        goodsTypePicData.value = res.data;
    }

    onBeforeRouteUpdate((to) => {
        getGoodsTypePicDataById(to.params.id)
    })

    onMounted(() => {
        getGoodsTypePicDataById();
    })

    return {
        goodsTypePicData
    }
}